package Xiaofang.Homework;

import javax.imageio.IIOException;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Work1 {
    public static void main(String[] args) throws Exception {
        Scanner input=new Scanner(System.in);
        String zhi=null;
        InputStreamReader is= null;
        try {
            is = new InputStreamReader(new FileInputStream("D:\\Xiaofang\\水浒传.txt"),"GBK");
            BufferedReader br=new BufferedReader(is);
            System.out.println("请输入名字：");
            String name=input.next();
            while ((zhi=br.readLine())!=null){
                if(zhi.indexOf(name)>0){
                    System.out.println(zhi.substring(7,11));
                }
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
}
